package com.example.wangfanwangluo.wangfanboss;

import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.text.InputType;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.example.wangfanwangluo.wangfanboss.widget.SwitchButton;

public class OldPwchange_login extends AppCompatActivity {
    private Typeface iconfont;
    private TextView exitv;
    private EditText oldet;
    private EditText newet;
    private SwitchButton oldsw;
    private SwitchButton newsw;
    private Button savebtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_old_pwchange_login);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        ActionBar actionbar = getSupportActionBar();
        if (actionbar != null){
            actionbar.hide();
        }
        initViews();

    }
    //初始化ui
    private void initViews(){
        iconfont = Typeface.createFromAsset(getAssets(), "iconfont/iconfont.ttf");
        exitv = (TextView)findViewById(R.id.exitbtn_oldpw);
        exitv.setTypeface(iconfont);
       oldet = (EditText)findViewById(R.id.oldedit);
       newet  = (EditText)findViewById(R.id.newedit);
        oldsw = (SwitchButton)findViewById(R.id.switch_old);
        newsw = (SwitchButton)findViewById(R.id.switch_new);
        savebtn = (Button)findViewById(R.id.savebtn_oldpw);
        exitv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //回到个人中心界面
               finish();
            }
        });
        savebtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //回到个人中心界面
                Intent intent = new Intent(OldPwchange_login.this,mine.class);
                startActivity(intent);
            }
        });
        //点击switch密文／明文显示切换
        oldsw.setOnCheckedChangeListener(new SwitchButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(SwitchButton view, boolean isChecked) {
                if (isChecked) {
                    oldet.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
                } else {
                    oldet.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
                }
            }
        });
        newsw.setOnCheckedChangeListener(new SwitchButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(SwitchButton view, boolean isChecked) {
                if (isChecked) {
                    newet.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
                } else {
                    newet.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
                }
            }
        });


    }
}
